<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>QxOrm: C:/Dvlp/_Perso/QxOrm/include/QxMemLeak/fixed_mem_pool.h File Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="logo_qxorm.png"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">QxOrm
   &#160;<span id="projectnumber">1.4.3</span>
   </div>
   <div id="projectbrief">C++ Object Relational Mapping library</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('fixed__mem__pool_8h.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#namespaces">Namespaces</a> &#124;
<a href="#define-members">Defines</a>  </div>
  <div class="headertitle">
<div class="title">fixed_mem_pool.h File Reference<div class="ingroups"><a class="el" href="group___qx_mem_leak.html">QxMemLeak : QxOrm library memory leak detection (by Wu Yongwei)</a></div></div>  </div>
</div>
<div class="contents">
<div class="textblock"><code>#include &lt;new&gt;</code><br/>
<code>#include &lt;assert.h&gt;</code><br/>
<code>#include &lt;stdlib.h&gt;</code><br/>
<code>#include &quot;<a class="el" href="class__level__lock_8h_source.html">class_level_lock.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="mem__pool__base_8h_source.html">mem_pool_base.h</a>&quot;</code><br/>
</div>
<p><a href="fixed__mem__pool_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classqx_1_1memory_1_1fixed__mem__pool.html">qx::memory::fixed_mem_pool&lt; _Tp &gt;</a></td></tr>
<tr><td colspan="2"><h2><a name="namespaces"></a>
Namespaces</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">namespace &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespaceqx.html">qx</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight"><p>Root namespace for all QxOrm library features. </p>
<br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">namespace &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespaceqx_1_1memory.html">qx::memory</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight"><p>QxOrm library memory leak detection (by Wu Yongwei) </p>
<br/></td></tr>
<tr><td colspan="2"><h2><a name="define-members"></a>
Defines</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="fixed__mem__pool_8h.html#a8750591dbb5b93d67f2e8df34cc37191">MEM_POOL_ALIGNMENT</a>&#160;&#160;&#160;4</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="fixed__mem__pool_8h.html#ab3b9223dee01caade508c782883b29b9">DECLARE_FIXED_MEM_POOL</a>(_Cls)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="fixed__mem__pool_8h.html#a72d9a5ebd3ea6036040bab35e7446bfe">DECLARE_FIXED_MEM_POOL__NOTHROW</a>(_Cls)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="fixed__mem__pool_8h.html#a066172d8410e9c4f09f4d2c2e02ffe49">DECLARE_FIXED_MEM_POOL__THROW_NOCHECK</a>(_Cls)</td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Definition of a fixed-size memory pool template for structs/classes. This is a easy-to-use class template for pre-allocated memory pools. The client side needs to do the following things:</p>
<ul>
<li>Use one of the macros <a class="el" href="fixed__mem__pool_8h.html#ab3b9223dee01caade508c782883b29b9">DECLARE_FIXED_MEM_POOL</a>, <a class="el" href="fixed__mem__pool_8h.html#a72d9a5ebd3ea6036040bab35e7446bfe">DECLARE_FIXED_MEM_POOL__NOTHROW</a>, and <a class="el" href="fixed__mem__pool_8h.html#a066172d8410e9c4f09f4d2c2e02ffe49">DECLARE_FIXED_MEM_POOL__THROW_NOCHECK</a> at the end of the class (say, <code>class</code> <em>_Cls</em>) definitions</li>
<li>Call fixed_mem_pool&lt;_Cls&gt;::initialize at the beginning of the program</li>
<li>Optionally, specialize fixed_mem_pool&lt;_Cls&gt;::bad_alloc_handler to change the behaviour when all memory blocks are allocated</li>
<li>Optionally, call fixed_mem_pool&lt;_Cls&gt;::deinitialize at exit of the program to check for memory leaks</li>
<li>Optionally, call fixed_mem_pool&lt;_Cls&gt;::get_alloc_count to check memory usage when the program is running</li>
</ul>
<dl class="version"><dt><b>Version:</b></dt><dd>1.14, 2005/09/19 </dd></dl>
<dl class="author"><dt><b>Author:</b></dt><dd>Wu Yongwei </dd></dl>

<p>Definition in file <a class="el" href="fixed__mem__pool_8h_source.html">fixed_mem_pool.h</a>.</p>
</div><hr/><h2>Define Documentation</h2>
<a class="anchor" id="ab3b9223dee01caade508c782883b29b9"></a><!-- doxytag: member="fixed_mem_pool.h::DECLARE_FIXED_MEM_POOL" ref="ab3b9223dee01caade508c782883b29b9" args="(_Cls)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define DECLARE_FIXED_MEM_POOL</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">_Cls</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<b>Value:</b><div class="fragment"><pre class="fragment"><span class="keyword">public</span>: \
    static <span class="keywordtype">void</span>* <a class="code" href="debug__new_8h.html#a81b855a55252e5b6a6e85ba96caf5361">operator new</a>(<span class="keywordtype">size_t</span> __size) \
    { \
        assert(__size == <span class="keyword">sizeof</span>(_Cls)); \
        if (<span class="keywordtype">void</span>* __ptr = fixed_mem_pool&lt;_Cls&gt;::allocate()) \
            return __ptr; \
        else \
            throw std::bad_alloc(); \
    } \
    static <span class="keywordtype">void</span>  <a class="code" href="debug__new_8h.html#a4f371aa078e7a0c8f30404c56f5f5dec">operator delete</a>(<span class="keywordtype">void</span>* __ptr) \
    { \
        if (__ptr != NULL) \
            fixed_mem_pool&lt;_Cls&gt;::deallocate(__ptr); \
    }
</pre></div><p>Declares the normal (exceptionable) overload of <b>operator new</b> and <b>operator delete</b>.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">_Cls</td><td>class to use the fixed_mem_pool </td></tr>
  </table>
  </dd>
</dl>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="fixed__mem__pool_8h.html#a066172d8410e9c4f09f4d2c2e02ffe49">DECLARE_FIXED_MEM_POOL__THROW_NOCHECK</a>, which, too, defines an <b>operator <a class="el" href="mem__leak_8h.html#a1ac41480eb2e4aadd52252ee550b630a">new</a></b> that will never return <code>NULL</code>, but requires more discipline on the programmer's side. </dd></dl>

<p>Definition at line <a class="el" href="fixed__mem__pool_8h_source.html#l00267">267</a> of file <a class="el" href="fixed__mem__pool_8h_source.html">fixed_mem_pool.h</a>.</p>

</div>
</div>
<a class="anchor" id="a72d9a5ebd3ea6036040bab35e7446bfe"></a><!-- doxytag: member="fixed_mem_pool.h::DECLARE_FIXED_MEM_POOL__NOTHROW" ref="a72d9a5ebd3ea6036040bab35e7446bfe" args="(_Cls)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define DECLARE_FIXED_MEM_POOL__NOTHROW</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">_Cls</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<b>Value:</b><div class="fragment"><pre class="fragment"><span class="keyword">public</span>: \
    static <span class="keywordtype">void</span>* <a class="code" href="debug__new_8h.html#a81b855a55252e5b6a6e85ba96caf5361">operator new</a>(<span class="keywordtype">size_t</span> __size) <span class="keywordflow">throw</span>() \
    { \
        assert(__size == <span class="keyword">sizeof</span>(_Cls)); \
        return fixed_mem_pool&lt;_Cls&gt;::allocate(); \
    } \
    static <span class="keywordtype">void</span>  <a class="code" href="debug__new_8h.html#a4f371aa078e7a0c8f30404c56f5f5dec">operator delete</a>(<span class="keywordtype">void</span>* __ptr) \
    { \
        if (__ptr != NULL) \
            fixed_mem_pool&lt;_Cls&gt;::deallocate(__ptr); \
    }
</pre></div><p>Declares the non-exceptionable overload of <b>operator new</b> and <b>operator delete</b>.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">_Cls</td><td>class to use the fixed_mem_pool </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="fixed__mem__pool_8h_source.html#l00289">289</a> of file <a class="el" href="fixed__mem__pool_8h_source.html">fixed_mem_pool.h</a>.</p>

</div>
</div>
<a class="anchor" id="a066172d8410e9c4f09f4d2c2e02ffe49"></a><!-- doxytag: member="fixed_mem_pool.h::DECLARE_FIXED_MEM_POOL__THROW_NOCHECK" ref="a066172d8410e9c4f09f4d2c2e02ffe49" args="(_Cls)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define DECLARE_FIXED_MEM_POOL__THROW_NOCHECK</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">_Cls</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<b>Value:</b><div class="fragment"><pre class="fragment"><span class="keyword">public</span>: \
    static <span class="keywordtype">void</span>* <a class="code" href="debug__new_8h.html#a81b855a55252e5b6a6e85ba96caf5361">operator new</a>(<span class="keywordtype">size_t</span> __size) \
    { \
        assert(__size == <span class="keyword">sizeof</span>(_Cls)); \
        return fixed_mem_pool&lt;_Cls&gt;::allocate(); \
    } \
    static <span class="keywordtype">void</span>  <a class="code" href="debug__new_8h.html#a4f371aa078e7a0c8f30404c56f5f5dec">operator delete</a>(<span class="keywordtype">void</span>* __ptr) \
    { \
        if (__ptr != NULL) \
            fixed_mem_pool&lt;_Cls&gt;::deallocate(__ptr); \
    }
</pre></div><p>Declares the exceptionable, non-checking overload of <b>operator new</b> and <b>operator delete</b>.</p>
<p>N.B. Using this macro <em>requires</em> users to explicitly specialize fixed_mem_pool::bad_alloc_handler so that it shall never return <code>false</code> (it may throw exceptions, say, <code>std::bad_alloc</code>, or simply abort). Otherwise a segmentation fault might occur (instead of returning a <code>NULL</code> pointer).</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">_Cls</td><td>class to use the fixed_mem_pool </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="fixed__mem__pool_8h_source.html#l00314">314</a> of file <a class="el" href="fixed__mem__pool_8h_source.html">fixed_mem_pool.h</a>.</p>

</div>
</div>
<a class="anchor" id="a8750591dbb5b93d67f2e8df34cc37191"></a><!-- doxytag: member="fixed_mem_pool.h::MEM_POOL_ALIGNMENT" ref="a8750591dbb5b93d67f2e8df34cc37191" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MEM_POOL_ALIGNMENT&#160;&#160;&#160;4</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Defines the alignment of memory blocks. </p>

<p>Definition at line <a class="el" href="fixed__mem__pool_8h_source.html#l00075">75</a> of file <a class="el" href="fixed__mem__pool_8h_source.html">fixed_mem_pool.h</a>.</p>

</div>
</div>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="fixed__mem__pool_8h.html">fixed_mem_pool.h</a>      </li>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


    <li class="footer">Generated on Sun Dec 11 2016 13:41:07 for QxOrm by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
